package com.JZ.QM.controller;

import com.JZ.QM.common.entity.TradeLDetailEntity;
import com.JZ.QM.common.utils.CommonResult;
import com.JZ.QM.service.TradeRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;

/**
 * @author: cyc
 * @email cyc@gmail.com
 * @date: 2020/7/5 10:05
 */
@RestController
@RefreshScope
@Slf4j
@RequestMapping(value="/tradeRecord")
public class TradeRecordController {
    @Resource
    TradeRecordService tradeRecordService;

    /**
     * 获取用户的额交易记录
     * @param tradeId 用户的交易记录id
     * @param userId 用户id
     * @return
     */
    @RequestMapping("/tradeRecordLists")
    public CommonResult getTradeRecordLists(Long tradeId,Long userId){
        //交易记录信息列表
        ArrayList<TradeLDetailEntity> tradeLDetailEntities=new ArrayList<>();

        //获取交易信息列表
        tradeLDetailEntities=tradeRecordService.getTradeRecords(tradeId,userId);
        return CommonResult.success().put("tradeRecords",tradeLDetailEntities);
    }

    /**
     * 获取银行与账户的交易信息
     * @param tradeId 用户的交易记录id
     * @param userId 用户id
     * @return
     */
    @RequestMapping("/tradeRecordListsOfBank")
    public CommonResult getTradeRecordListsOfBank(Long tradeId,Long userId){
        //银行信息交易记录信息列表
        ArrayList<TradeLDetailEntity> tradeLDetailEntities=new ArrayList<>();

        //获取交易信息列表
        tradeLDetailEntities=tradeRecordService.getTradeRecordsOfBank(tradeId,userId);
        return CommonResult.success().put("tradeRecordsOfBank",tradeLDetailEntities);
    }


}
